package com.beyondsoft.dtc.mobile.automation.model;

import com.beyondsoft.dtc.mobile.automation.base.GlobalConstants;
import com.beyondsoft.dtc.mobile.automation.util.StringUtil;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
 * Created by Robin on 3/11/2016.
 */
public class Device {

	// branch comment: '品牌 比如魅族'
	// dVersion comment: '设备版本 比如 mx5'
	// resolution comment: '分辨率'
	// screenSize comment: '屏幕尺寸'
	// sysVersion comment: '系统版本'
	// sysUIType
	// sysType comment: '系统类型 andriod ios wp'
	// serialNumber comment: '序列号'
	// macAddress comment: '手机mac'
	// createBy comment: '创建人'
	// cpuBrand comment: 'cpu厂商'
	// cpuVersion comment: 'cpu型号'
	// gHz comment: 'cpu主频'
	// rom comment: '机身内存 ROM'
	// ram comment: '运行内存'
	// connetType comment: '连接类型 wifi usb'
	// ip comment: '如果是wifi 需填写'
	//
	// isUsed comment: '是否占用'
	// photo comment: '图片地址'

	public String getSysType() {
		return sysType;
	}

	public void setSysType(String sysType) {
		this.sysType = sysType;
	}

	private String sysType;
	private String branch;
	private String dVersion;
	private String resolution;
	private double screenSize;
	private String sysVersion;
	private String macAddress;
	private String cpuBrand;
	private String cpuVersion;

	public String getSysUIType() {
		return sysUIType;
	}

	public void setSysUIType(String sysUIType) {
		this.sysUIType = sysUIType;
	}

	private String sysUIType;
	private String gHz;
	private String rom;
	private String ram;

	public String getBranch() {
		return branch;
	}

	public void setBranch(String branch) {
		this.branch = branch;
	}

	public String getdVersion() {
		return dVersion;
	}

	public void setdVersion(String dVersion) {
		this.dVersion = dVersion;
	}

	public String getResolution() {
		return resolution;
	}

	public void setResolution(String resolution) {
		this.resolution = resolution;
	}

	public double getScreenSize() {
		return screenSize;
	}

	public void setScreenSize(double screenSize) {
		this.screenSize = screenSize;
	}

	public String getSysVersion() {
		return sysVersion;
	}

	public void setSysVersion(String sysVersion) {
		this.sysVersion = sysVersion;
	}

	public String getMacAddress() {
		return macAddress;
	}

	public void setMacAddress(String macAddress) {
		this.macAddress = macAddress;
	}

	public String getCpuBrand() {
		return cpuBrand;
	}

	public void setCpuBrand(String cpuBrand) {
		this.cpuBrand = cpuBrand;
	}

	public String getCpuVersion() {
		return cpuVersion;
	}

	public void setCpuVersion(String cpuVersion) {
		this.cpuVersion = cpuVersion;
	}

	public String getgHz() {
		return gHz;
	}

	public void setgHz(String gHz) {
		this.gHz = gHz;
	}

	public String getRom() {
		return rom;
	}

	public void setRom(String rom) {
		this.rom = rom;
	}

	public String getRam() {
		return ram;
	}

	public void setRam(String ram) {
		this.ram = ram;
	}

	private String taskId;

	@Expose
	@SerializedName("device_id")
	private String deviceId = "";// 设备id

	@Expose
	@SerializedName("connect_type")
	private String connectType = "usb";// 定义链接方式

	@Expose
	@SerializedName("serial_number")
	private String serialNumber = "";// 定义设备

	@Expose
	@SerializedName("device_ip")
	private String deviceIp = "";// 无线对应的ip

	public String getTaskId() {
		return taskId;
	}

	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}

	public String getDeviceId() {
		return deviceId;
	}

	public void setDeviceId(String deviceId) {
		this.deviceId = deviceId;
	}

	public String getConnectType() {
		return connectType;
	}

	public void setConnectType(String connectType) {
		this.connectType = connectType;
	}

	public String getSerialNumber() {
		return serialNumber;
	}

	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}

	public String getDeviceIp() {
		return deviceIp;
	}

	public void setDeviceIp(String deviceIp) {
		this.deviceIp = deviceIp;
	}

	/**
	 * if it's usb device, connectAddress will be serial number, other, it's ip
	 * address.
	 *
	 * @return serial number or ip address.
	 */
	public String getConnectAddress() {
		return (isUSBDevice() ? serialNumber : deviceIp).trim();
	}

	public boolean isUSBDevice() {
		return GlobalConstants.DEFAULT_DEVICE_CONNECTION_TYPE_USB
				.equalsIgnoreCase(connectType)
				&& !StringUtil.isEmpty(serialNumber);
	}

	@Override
	public String toString() {
		return "Device{" + "taskId='" + taskId + '\'' + ", deviceId='"
				+ deviceId + '\'' + ", connectType='" + connectType + '\''
				+ ", serialNumber='" + serialNumber + '\'' + ", deviceIp='"
				+ deviceIp + '\'' + '}';
	}
}
